#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QWebView>
#include <QList>
#include "documentdate.h"
#include "configset.h"

typedef struct{
    int titleNumber;
    int contentNumber;
    int maxNumber;
}PageSetStruct;

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    virtual ~MainWindow();

    QString getHtml(QString url);

public slots:
     void on_webView_loadFinished();
     void on_webView_loadFinished_geturl();
     void on_toChangerUrl(QString url);
     void on_toChangerGetUrlEnd();
 signals:
     void toChangeUrl(QString url);
     void toChanegeGetUrlEnd();

protected:
     QString m_hostUrl;
     PageSetStruct m_pageSet;
     typedef struct {
         QString url;
         ConfigSetItem configItem;
     } UrlData;
     QList<UrlData> m_urlList;
     QList<UrlData>::iterator m_urlListIt;
     QList<DocumentDate> m_docList;

     ConfigSet m_configSet;
     QList<ConfigSetItem>::iterator m_configSetItemIt;

     void addUrl(QString pathUrl, QString hostUrl,ConfigSetItem configItem);
     void addDoucment(DocumentDate doc);
     void finshedAddUrl();

     void loadDataToListView();
     void loadDataToListView(QList<DocumentDate> docList);

private slots:
     void on_listView_doubleClicked(const QModelIndex &index);

     void on_search_btn_clicked();

     void on_lineEdit_returnPressed();

private:
    Ui::MainWindow *ui;
    QWebView *webView;
    QWebView *webView_url;

};

#endif // MAINWINDOW_H
